// 聊天室菜单
<template>
    <div>
        <div class="menuBox flex ">
            <div class="menuBox-left flex flex-align-center flex-pack-center">
                <div class="chatRoomBtn">
                    <p>对话框</p>
                    <div class="liaotBtnBox flex flex-align-center flex-pack-center" :class="{btnActive:isActive==1}" @click="onToChatRoomFun">
                        <p>聊天室</p>
                    </div>
                </div>
            </div>
            <div class="menuBox-right" v-if='$store.state.userInfo.member_type_int != 0'>
                <div class="menuBox-BtnBox">
                    <p>会员管理</p>
                    <div class="btnGroup flex">
                        <div class="liaotBtnBox flex flex-align-center flex-pack-center" :class="{btnActive:isActive==2}" @click="onAddUser">
                            <p>新增用户</p>
                        </div>
                        <div class="liaotBtnBox flex flex-align-center flex-pack-center" :class="{btnActive:isActive==3}" @click="onGetSuperior">
                            <p>上级人员</p>
                        </div>
                        <div class="liaotBtnBox flex flex-align-center flex-pack-center" :class="{btnActive:isActive==4}" @click="onUserList">
                            <p>会员列表</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
export default {
    data () {
        return {
            isActive:1
        }
    },
    methods: {
        onToChatRoomFun(){ //点击聊天室
            this.isActive =1;
            this.$emit('tochatroom');
        },
        onAddUser(){ //新增用户
            this.$emit('adduser');
        },
        onGetSuperior(){ //查看上级
            this.isActive =1;
            this.$emit('opensuper');
            let uid = this.$store.state.userInfo.id;
            this.https('Chat/postObtainUserParentInfo',{uid:uid})
            .then(data => {
                 this.getNetMessage(uid,'',data.id,1);
                 let userInfo = {name:data.nickname,id:data.id,group_id:''}
                 this.$store.commit('setToUserInfo',userInfo);
            })
        },
        getNetMessage(uid,group_id,from_uid,page){ //获取历史消息
            this.https('chat/postObtainMessageRecordLimit',{uid:uid,group_id:group_id,from_uid:from_uid,page},'post')
            .then(data =>{
                    let root = [];
                    for(var i = data.data.length-1;i>=0;i--){
                        root.push(data.data[i]);
                    }
                    this.$store.commit('setAllMsgList',root);
                    this.https('chat/postUpdateMessageStatus',{uid:uid,group_id:group_id,from_uid:from_uid},'post')
                    .then(data => {
                    });
            })
        },
        onUserList(){ // 会员列表
             this.isActive = 4;
             this.$emit('touserlist');
        }
    }
}
</script>
<style lang="less" scoped>
@import url(../../../assets/css/chatroom/chatroommenu.less);
</style>


